class create IMM1 {
    constructor { {parameters {} } } {
	my variable par
	#default par	
	array set par { 
	    membrane on
	    aemp 0.85
	    nsmth 10
	    thick 27
	    gouy off
	    anionic% 30
	    area/lipid 65
	    ionConc 0.1
	    ionCharge 1
	} 	
	my configure $parameters
    }
    method configure { parameters } {
	my variable par
	array set par $parameters
    }
    method getCmd {} {}
}
#core
oo::define IMM1 method getCmd {} {
	my variable par
	if [info exists par(width)] { set par(nsmth) [expr ceil(log(9)/log(1+2*$par(width)/$par(thick)))] }
	if { $par(membrane) == off } {
	    set cmd "eef1 setup temp $par(temperature) unit 93 name $par(solvpar)\n"
	} else {
	    set cmd "eef1 setup membrane slvt water slv2 chex nsmth $par(nsmth) width $par(thick) temp $par(temperature) -\n unit 93 name $par(solvpar) aemp $par(aemp) "
	    if [info exists par(TMpotential) ] { set $par(gouy) on ; append cmd " -\n volt $par(TMpotential) " } 
	    if [info exists par(pb)] {
		set $par(gouy) on
		append cmd " -\n pb $par(pb)"
	    }
	    if [info exists par(shape)] {
		append cmd "-n shape $par(shape) "
	    }
	    if { $par(gouy) == on } {
		append cmd " - \n gouy anfr [expr 0.01*$par(anionic%)] area $par(areaperlipid) offset $par(width) conc $par(ionConc) valence $par(ionCharge) "   
	    }
	    if [info exists par(pore)] {
		switch $par(pore) {
		    toroidal {
			append cmd " -\n rprp $par(radius) aprp $par(curvature) " 
		    }
		    cylindrical {
			append cmd " -\n rprp $par(radius) aprp 0.0 "
		    }
		    
		}
	    }
	}
	append cmd "\n update ctonnb 7. ctofnb 9. cutnb 10. group rdie " 
	return $cmd
    }


IMM1 create IMM1_water {
    membrane off
    solvpar ~/simulation/common/solvpar.new.inp
    temperature 298
}
IMM1 create IMM1_memb {
    membrane on
    gouy off 
    solvpar ~/simulation/common/solvpar.new.inp
    temperature 298
    thick 27
}
IMM1 create IMM1_anionic {
    membrane on
    gouy on
    solvpar ~/simulation/common/solvpar.new.inp
    temperature 298
    anionic% 15
    width 3.0
}
